package com.yuexun.dhdoctor.module.Contract.presenter.impl;


import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.Contract.bean.ShareHospBean;
import com.yuexun.dhdoctor.module.Contract.model.IShareHospModel;
import com.yuexun.dhdoctor.module.Contract.presenter.IShareHospPresenter;
import com.yuexun.dhdoctor.module.Contract.ui.view.IShareHospView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenss on 2018/1/26 0026.
 */

public class ShareHospPresenter implements IShareHospPresenter {

    private IShareHospView view;
    private IShareHospModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public ShareHospPresenter(IShareHospModel model, IShareHospView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void inquireShareHospList(Map<String, String> praise) {
        model.inquireShareHospList(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<ShareHospBean>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("获取共享的医院失败:" + e.toString());
                    }

                    @Override
                    public void onNext(BaseEntity<ShareHospBean> baseEntity) {
                        view.getHospList(baseEntity);
                    }
                });
    }
}
